@extends('admin.master')

@section('style')
	<link rel="stylesheet" href="{{ url('css/bootstrap-datetimepicker.css') }}">
@endsection

@section('top')
<div class="top-breadcrumb pull-left">{!! Breadcrumbs::render('order-manager') !!}</div>
@endsection

@section('content')
<div class="section-search mb10" id="order-manager">
	{!! Form::model($where, ['method'=>'get', 'class'=>'form-inline']) !!}
	<div class="form-block">
		<div class="form-group">
			{!! Form::text('word', null, ['class'=>'form-control len', 'placeholder'=>'客户名称或域名']) !!}
		</div>
		<div class="form-group">
			{!! Form::select('date_field', [1=>'签单日期', 5=>'上线日期'], null, ['class'=>'form-control autosize']) !!}
			<div class="form-datetime datetime-search len150">
				{!! Form::text('start', null, ['class'=>'form-control len150 datetimepicker-start', 'data-date-format'=>'yyyy-mm-dd']) !!}
				<i class="icon icon-date"></i>
			</div>
			<span class="date-step-span">至</span>
			<div class="form-datetime datetime-search len150">
				{!! Form::text('end', null, ['class'=>'form-control len150 datetimepicker-end', 'data-date-format'=>'yyyy-mm-dd']) !!}
				<i class="icon icon-date"></i>
			</div>
		</div>
		<div class="form-group">
			<label class="control-label">业务员：</label>
			{!! Form::select('saler_id', $salers, null, ['class'=>'form-control autosize']) !!}
		</div>
		<div class="form-group">
			<label class="control-label">到期：</label>
			{!! Form::select('duetime', $system['duetime'], null, ['class'=>'form-control autosize duetime-check']) !!}
		</div>
		<div class="form-group" v-if="!duetime_check">
			<label class="control-label">状态：</label>
			{!! Form::select('status', ['全部订单']+$system['order_status'], null, ['class'=>'form-control autosize']) !!}
		</div>
		<div class="form-group" v-if="!duetime_check">
			<label class="control-label">订单类型：</label>
			{!! Form::select('product', ['全部订单'] + config('system.product.1')+config('system.product.2'), null, ['class'=>'form-control autosize']) !!}
		</div>
		<div class="form-group">
			<div class="checkbox">
				<label>{!! Form::checkbox('tail', 1, null) !!} 尾款</label>		
			</div>
		</div>
		<div class="form-group">
			<button type="submit" class="btn btn-primary">查询订单</button>
		</div>
		<a href="javascript:void(0)" id="toExcel" class="btn btn-link margin-top pull-right">导出列表</a>
	</div>
{!! Form::close() !!}
</div>
<div class="gridSection">
{!! Form::open(['url'=>'admin/order']) !!}
	<table class="table table-hover table-list">
		<thead>
			<tr>
				<th width="60" class="text-center">ID</th>
				<th class="text-center">签单时间</th>
				<th class="text-center">到期时间</th>
				<th>客户名称</th>
				<th class="text-center">年限</th>
				<th>订单类型</th>
				<th>标签</th>
				<th>套餐</th>
				<th class="text-nowrap">业务员</th>
				<th>域名</th>
				<th>签单金额</th>
				<th>尾款</th>
				<th>进度</th>
				<th class="text-center">操作</th>
			</tr>
		</thead>
		<tbody>
			@if (!$data->isEmpty())
				@foreach ($data as $value)
					<tr>
						<td class="text-center">{{ $value->id }}</td>
						<td class="text-center text-nowrap">{{ $value->signed_at->format('Y-m-d') }}</td>
						<td class="text-center text-nowrap">
							<span class="expired-time">{{ $value->expired_at->format('Y-m-d') }}</span>
						</td>
						<td width="200">
						{{ $value->customer->name }}
						@if ($value->expedited)
							<span class="label label-warning">加急</span>
						@endif
						</td>
						<td class="text-center">{{ $value->year }}</td>
						<td>
							<span class="label label-info">{{ $system['product'][$value->type][$value->product] }}</span>
						</td>
						<td><span class="text-warning">{{ $value->tag }}</span></td>
						<td>
						@if ($value->web_package)
							<span class="text-success">{{ config('system.web_package')[$value->web_package] }}</span>
						@endif
						</td>
						<td>{{ $value->saler->name or '' }}</td>
						<td><a href="http://{{ $value->domain }}" target="_blank">{{ $value->domain }}</a></td>
						<td><span class="text-success">{{ (int)$value->amount }}</span></td>
						<td>
							@if ($value->tail_amount > 0)
								<span class="text-danger">{{ (int)$value->tail_amount }}</span>
							@else
								<span class="text-muted">/</span>
							@endif
						</td>
						<td><span class="text-success">{{ $system['order_status'][$value->status] }}</span></td>
						<td class="text-center text-nowrap">
							<a href="{{ route('admin.order.show', [$value->id, 'u'=>1]) }}" class="btn-link">查看</a>
						</td>
					</tr>
				@endforeach
			@endif
		</tbody>
	</table>
	@if (!$data->isEmpty())
	<table class="table table-footer table-fixed">
		<tfoot>
			<tr>
				<td>
					<div class="pagination-box">
						<div class="pull-right">
							<div class="pagination-info">共有{{ $data->total() }}条， 每页显示：20条</div>
							{!! $data->appends(request()->except('page'))->render() !!}
						</div>
					</div>				
				</td>
			</tr>
		</tfoot>
	</table>
	@else
	<div class="simple-none-data text-center">
		<i class="fa fa-exclamation-circle text-size-20 text-muted" style="vertical-align: middle"></i> 
		<span class="text-size-14 inline-block ml5">没有查询到符合条件的记录</span>
	</div>
	@endif
{!! Form::close() !!}
</div>
@endsection

@section('foot')
<script src="{{ url('js/bootstrap.min.js') }}"></script>
<script src="{{ url('js/bootstrap-datetimepicker.js') }}"></script>
<script type="text/javascript">

	$('.datetimepicker-start').datetimepicker({
		language: 'zh-CN',
		autoclose: true,
		todayBtn: true,
		minView: 'month'
	});
	$('.datetimepicker-end').datetimepicker({
		language: 'zh-CN',
		autoclose: true,
		todayBtn: true,
		minView: 'month'
	});

	// 导出Excel
	$('#order-export').on('click', function() {
		var url = location.href + '&export=1';
		location.href = url;
	});
</script>	
@endsection